import request from "@/utils/request";
import {ApiResponse, AtLeastOne} from "@/types/api";

const BASE_URL = '/config'

type ConfigResp = ApiResponse<{
  enable_req_debug: boolean;
  cci: string[];
}>

interface UpdateReq {
  /** 是否开启调试 */
  enable_req_debug?: boolean;
  /** CCI配置项 */
  cci?: string[];
}


export const configApi = {
  /** 获取配置 */
  get: (): Promise<ConfigResp> => request.get(BASE_URL),

  /** 更新配置（至少需要传递一个字段） */
  update: (req: AtLeastOne<UpdateReq>) => request.put(BASE_URL, req),
}
